# _*_ coding:utf-8 _*_
# @File  : __init__.py.py
# @Time  : 2022-01-11  17:05
# @Author: zizle

class AllResponse(object):
    SUCCESSFULLY = 200
    CREATED_SUCCESS = 201
    NO_CONTENT = 204
    NO_DO_ANYTHING = 299

    NO_AUTHORIZATION = 401
    FORBIDDEN_ERROR = 403
    VALIDATE_ERROR = 422

    SERVER_ERROR = 500

    @classmethod
    def operate_successfully(cls, data=None, msg='操作成功'):
        return {'code': cls.SUCCESSFULLY, 'msg': msg, 'data': data}

    @classmethod
    def create_successfully(cls, data=None, msg='创建数据成功!'):
        return {'code': cls.CREATED_SUCCESS, 'msg': msg, 'data': data}

    @classmethod
    def server_no_content(cls, data=None, msg='数据不存在!'):
        return {'code': cls.NO_CONTENT, 'msg': msg, 'data': data}

    @classmethod
    def no_do_anything(cls, data=None, msg='无需进行此操作!'):
        return {'code': cls.NO_DO_ANYTHING, 'msg': msg, 'data': data}

    @classmethod
    def no_authorization(cls, data=None, msg='登录已过期或没有权限'):
        return {'code': cls.NO_AUTHORIZATION, 'msg': msg, 'data': data}

    @classmethod
    def forbidden_error(cls, data=None, msg='您不允许进行这项操作!'):
        return {'code': cls.FORBIDDEN_ERROR, 'msg': msg, 'data': data}

    @classmethod
    def validate_error(cls, data=None, msg='参数错误'):
        return {'code': cls.VALIDATE_ERROR, 'msg': msg, 'data': data}

    @classmethod
    def server_error(cls, data=None, msg='操作失败,服务器错误!'):
        return {'code': cls.SERVER_ERROR, 'msg': msg, 'data': data}

